Shader "Unlit/Book2"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _Height ("Height", Float) = 20
        _Center("Center", Vector) = (0,0,0,0)
        _R("R", Float) = 1
        _Highlight("Highlight", Float) = 10
    }
    SubShader
    {
        Tags
        {
            "RenderType"="Opaque"
        }
        LOD 100

        Pass
        {
            Cull Off
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_fog
            #include "UnityCG.cginc"


            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            //指定的uv点
            float4 _Center;
            float _Height;
            //圆的半径
            float _R;
            float _Highlight;


            float GetDeltaY(float2 pos)
            {
                return sqrt(1 - pow(pos.x - 0.5, 2)) + 0.5;
            }

            v2f vert(appdata_base v)
            {
                v2f o;
                o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);

                float4 pos = v.vertex;
                float a = _Center.y / _Center.x;
                if (o.uv.y <= _Center.y * o.uv.x)
                {
                    //先处理为不渲染这个顶点
                    // v.vertex = float4(0,0,0,0);
                    v.vertex = _Highlight * float4(o.uv.x * (1 - a) / (1 + a * a), 2 * a * o.uv.x / (1 + a * a), 0,
                                                   0);
                }
                o.vertex = UnityObjectToClipPos(v.vertex);

                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                return col;
            }
            ENDCG
        }
    }
}